<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/1
 * Time: 15:10
 */

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\Ad as Model;

class Ad extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    public function lists(Model $model)
    {
        $now = time();
        $ads = $model->where('switch',1)->whereTime('publishtime','<',$now)->whereTime('endtime','>',$now)
            ->order('weigh','desc')->field('id,title,image,url,publishtime,endtime')->select();
        $this->success('成功',$ads);
    }
}